package city.spring.modules.reception.service.impl;

import city.spring.modules.reception.entity.CheckInRecordEntity;
import city.spring.modules.reception.repository.CheckInRecordRepository;
import city.spring.modules.reception.service.CheckInRecordService;
import city.spring.modules.reception.vo.CheckInRecordVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Service：入住记录
 *
 * @author 侯坤林
 * @date 2020-05-23 02:19:24
 */
@CacheConfig(cacheNames = {CheckInRecordServiceImpl.CACHE_NAME})
@Transactional(rollbackFor = Throwable.class)
@Service
public class CheckInRecordServiceImpl extends ServiceImpl<CheckInRecordRepository, CheckInRecordEntity> implements CheckInRecordService {

    private final CheckInRecordRepository checkInRecordRepository;

    public CheckInRecordServiceImpl(CheckInRecordRepository checkInRecordRepository) {
        this.checkInRecordRepository = checkInRecordRepository;
    }

    @Override
    public List<CheckInRecordVO> queryAll(Wrapper<CheckInRecordEntity> wrapper) {
        return baseMapper.queryAll(wrapper);
    }

    @Override
    public Page<CheckInRecordVO> queryPage(Page page, Wrapper<CheckInRecordEntity> wrapper) {
        return baseMapper.queryPage(page, wrapper);
    }

    @Override
    public CheckInRecordEntity getLatestRecordByOldmanId(String oldmanId) {
        return checkInRecordRepository.getLatestRecordByOldmanId(oldmanId);
    }

    @Override
    public List<CheckInRecordEntity> getCheckInRecordListByOldmanId(String oldmanId) {
        return checkInRecordRepository.getCheckInRecordListByOldmanId(oldmanId);
    }

    @Override
    public void deleteCheckInRecord(String primaryKey) {
        removeById(primaryKey);
    }

    @Override
    public void deleteCheckInRecords(List<String> primaryKeys) {
        removeByIds(primaryKeys);
    }
}